package demo.methods;

public class PassingArgument {
	public static void main(String[] args)
	{
		if (args.length < 1) {
			System.out.println("Khong nhap doi so");
		}
		else {
			for (int i = 0; i < args.length; i++) {
				String tmp = args[i];
				if (tmp == null) {
					System.out.println("null");
				}
				else
					System.out.println(tmp);
			}
		}
		
		System.out.println("================");
		
		Person ps = new Person("qwe", 20);
		System.out.println("Dau tien ");
		System.out.println("ten: " + ps.getName());
		System.out.println("tuoi: " + ps.getAge());
		
		PassingArgument pa = new PassingArgument();
		pa.modifyPerson(ps);
		
		System.out.println("\nCuoi dung ");
		System.out.println("ten: " + ps.getName());
		System.out.println("tuoi: " + ps.getAge());
		
	}
	
	public void modifyPerson(Person ps)
	{
		ps.setAge(30);
		ps = new Person("asd", 25);
		System.out.println("\nSua doi ");
		System.out.println("ten: " + ps.getName());
		System.out.println("tuoi: " + ps.getAge());
	}
}

class Person
{
	private int age;
	private String name;
	public Person(String name, int age)
	{
		this.name = name;
		this.age = age;
	}
	
	public String getName()
	{
		return name;
	}
	
	public int getAge()
	{
		return age;
	}
	
	public void setAge(int age)
	{
		this.age = age;
	}
}